      SUBROUTINE JULDAY(IYEAR,MONTH,IDAY,XJD)
      IMPLICIT REAL*8 (A-H,O-Z)
C CONVERTS CALENDAR DATE INTO JULIAN DATE
      DIMENSION IMON(12)
C
C
      DATA IMON/0,31,28,31,30,31,30,31,31,30,31,30/
C
      NYEAR=IYEAR-1961
      NLEAP=NYEAR/4
      NYRDAY=NYEAR*365+NLEAP
C
C
      MODAY=0
      IF (MONTH.GT.2.AND.NYEAR-4*NLEAP.EQ.3) MODAY=1
      DO 10 I=1,MONTH
   10 MODAY=MODAY+IMON(I)
C
C JULIAN BASE DATE IS DEC 31,1960 = 2437299.5 (A.M. MIDNIGHT)
      XJD=NYRDAY+MODAY+IDAY+2437299.5D0
C
      RETURN
      ENTRY CALDAY(XJD,IYEAR,MONTH,IDAY,UT)
      XDAY=XJD-2437300.5D0
      IDAY=XDAY
      UT=(XDAY-IDAY)*86400.D0
      NYEAR=XDAY/365.25D0
      NLEAP=NYEAR/4
      ILEAP=NYEAR-4*NLEAP
      NYRDAY=IDAY+1-365*NYEAR-NLEAP
      IDAY=NYRDAY
      DO 20 I=2,12
      MONTH=I-1
      MODAY=IMON(I)
      IF (MONTH.EQ.2.AND.ILEAP.EQ.3) MODAY=MODAY+1
      IF (IDAY.LE.MODAY) GO TO 22
      IDAY=IDAY-MODAY
   20 CONTINUE
      MONTH=12
      IF (IDAY.LT.32) GO TO 22
      IDAY=1
      MONTH=1
      NYEAR=NYEAR+1
   22 IYEAR=NYEAR+1961
      RETURN
      END
